import express from 'express';
import path from 'path';
import { fileURLToPath } from 'url';

// 获取当前文件路径（ESM 替代 __dirname）
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const app = express();
const PORT = process.env.PORT || 5188;

app.use(express.static(path.join(__dirname, 'dist')));

app.get('*', (req, res) => {
  res.sendFile(path.join(__dirname, 'dist', 'index.html'));
});

app.listen(PORT, () => {
  console.log(`Node ${process.version}`);
  console.log(`Server running on port ${PORT}`);
});